// actions
import mearsuringPointSetting from "../../api/mearsuringPointSetting/index"

export default {
    // 获取所有桥梁
    // commit 是调用 mutations 用的, dispatch 是调用 actions 用的, state 是当前模块的 state,  rootState 是根 state
    async getBridgeAllList({ commit, dispatch, state, rootState }, value) {
        let data;
        await mearsuringPointSetting.getBridgeAll().then((res) => {
            data = res.data.data[0]
        })
        // console.log("根模块的state", rootState)
        commit("SETBRIDGEALLLIST", data)
    },

    //getPointTree 测点管理树
    async getPointTree({ commit }, value) {
        let data;
        await mearsuringPointSetting.getPointTree(value).then((res) => {
            data = res.data.data
            // console.log("获取到的测点管理树", res.data.data)
        })
        commit("GETPOINTTREE", data)
    },

    // 获取测点第二颗树
    async getPointNextTree({ commit }, value) {
        let data;
        await mearsuringPointSetting.getPointNextTree(value).then((res) => {
            data = res.data.data[0]
            // console.log("获取到的测点第二颗管理树", res.data.data[0])
        })
        commit("GETPOINTNEXTTREE", data)
    },

    // 获取部件下的测点列表
    async getPointList({ commit }, value) {
        let data;
        await mearsuringPointSetting.getPointList(value).then((res) => {
            data = res.data.data
            // console.log("测点列表", res.data.data)
        })
        commit("GETPOINTLIST", data)
    },
    // 获取桥梁下的所有测点列表
    async getBridgePointList({ commit }, value){
        let data;
        await mearsuringPointSetting.getBridgePointList(value).then(res=>{
            data = res.data.data
            // console.log("所有测点列表", res.data.data)
        })
        commit("GETPOINTLIST", data)
    },

    async getFirstType({ commit }, value){
        let data;
        await mearsuringPointSetting.getFirstType(value).then(res=>{
            data = res.data.data[0]
            // console.log("一级分类", res.data.data)
        })
        commit("FIRSTTYPE", data)
    },
    async getSecondType({ commit }, value){
        let data;
        await mearsuringPointSetting.getSecondType(value).then(res=>{
            data = res.data.data[0]
            console.log("二级分类", res.data.data)
        })
        commit("SECONDTYPE", data)
    },


}
